/* 注册通用方法 */
function regCommonClick(){
	regSlideUp();
	regSlideDown();
	regRemove();
}

/* 通用上拉方法 */
function regSlideUp(){
	 $(".fa-chevron-up").click(function(e) {								 			 
		 $(this).attr("class","fa fa-chevron-down");
		 $(this).parent().parent().parent().parent().find(".panel-body").slideUp(200);
		 $(this).unbind("click");
		 regSlideDown();			 
	 });	
}

/* 通用下拉方法 */
function regSlideDown(){
	$(".fa-chevron-down").click(function(e) {
		 $(this).attr("class","fa fa-chevron-up");
		 $(this).parent().parent().parent().parent().find(".panel-body").slideDown(200);
		 $(this).unbind("click");
		 regSlideUp();
	 });
}

/* 通用移除方法 */
function regRemove(){
	 $(".button-icon .fa-times").click(function(e) {			 
		 $(this).parent().parent().parent().parent().parent().remove();
	 });
}

/* 通用重置缓存方法 filterID：缓存标示 */
function regReloadCache(filterID){
	 $("#reloadCache").click(function(e){
		 
		 //调用后台
		 var msgExcute = new MonitorMsg();		 
		 var url = MUtil.getRootPath()+"/monitorService";		 
		 var param = {
			"serviceCode":"monitor",
			"classPath":"cn.lily.esb.monitor.control.node.cache.reload.CacheReloadNode",
			"traceId":"123123123",
			"url":url,
			"param":{
				"filter":filterID
			}
		 };		 
		 msgExcute.setParam(param);
		 msgExcute.post();
		 
		 $('.cacheModel').modal('hide');
		 
		 //页面刷新
		 location.reload();
	 });
}

/* 添加监控信息 */
function regMonitorAdd(){
	$("#addMonitor").click(function(e){
		
		 var ssl = "";
		 if($("#MT_comm_http").is(":checked")){
			 ssl = "http";
		 }else{
			 ssl = "https";
		 }
		
		 var msgExcute = new MonitorMsg();		 
		 var url = MUtil.getRootPath()+"/monitorService";		
		 var param = {
			"serviceCode":"monitor",
			"classPath":"cn.lily.esb.monitor.control.node.nav.MonitorNavNode",
			"traceId":"123123123",
			"monitorAppAuth":"",
			"url":url,		
			"param":{
				"appCode":$("#MT_appCode").val(),
				"appIDC":$("#MT_appIDC").val(),
				"ip":$("#MT_ip").val(),
				"port":$("#MT_port").val(),
				"ssl":ssl,
				"method":"add"
			}
		 };		 
		 msgExcute.setParam(param);
		 msgExcute.post();
		 
		 alert(msgExcute.getRspMsg());
		
		 $('.addModel').modal('hide');
		 //页面刷新
		 location.reload();
	}); 
}

/*监控系统数据刷新方法*/
function regMonitorRefresh(){
	var navTable = new Monitor();
    navTable.setParam({
		"esb":{
			"classPath":"nav.MonitorNavTableNode",
			"traceId":"123123123123",
			"monitorAppAuth":""
		},
		"web":{
			"divId":"monitorNav",
			"viewType":"navTable",
			"isCheck":true
		}
	});
	
    navTable.loadHTML();
}

/* 切换监控系统 */
function regExchange(){
	$(".exchangeMonitor").click(function(e){
		
		var appAuth = $(this).parent().parent().find(".appAuth").text().trim();
		
		$.ajax({
            type: "POST",
            url:MUtil.getRootPath()+"/frames/monitor/nav/monitor_exchange.jsp",
            processData: false,
            async: false,
            data: "appAuth="+appAuth,
            dataType: 'text', 
            success: function(data){
            	alert(data.trim());
            }
        });
		
		$('.exchangeModel').modal('hide');
		
		location.reload();
		
	});
}

/* 注册刷新 */
function regRefresh(){
	$(".monitorRef").click(function(e){
		regMonitorRefresh();
	});
}

/* 注册多选事件 */
function regCheck(){
	$(".allcheck").click(function(e){
		$("input[name='checkname']").attr('checked', this.checked);
	});
}

/*注册删除方法*/
function regDelete(){
	$(".monitorRemv").click(function(e){
		var appAuths = "";
		$("input[name='checkname']").each(function() {
			if($(this).is(":checked")){
				appAuths += $(this).parent().parent().find(".appAuth").text() + ",";
			}	        
		});
		if(appAuths == ""){
			alert("请至少选择一条记录！");
			return;
		}
		
		var msgExcute = new MonitorMsg();		 
		var url = MUtil.getRootPath()+"/monitorService";				 
		var param = {
			"serviceCode":"monitor",
			"classPath":"cn.lily.esb.monitor.control.node.nav.MonitorNavNode",
			"traceId":"123123123",
			"url":url,
			"monitorAppAuth":"",
			"param":{				
				"appAuth":appAuths,
				"method":"delete"
			}
		 };		 
		 msgExcute.setParam(param);
		 msgExcute.post();
		 
		 regMonitorRefresh();
		
	});
}

/* 注册退出方法 */
function regMonitorLoginOut(){
	$("#monitorLoginOut").click(function(e){			
		$.ajax({
            type: "POST",
            url:MUtil.getRootPath()+"/frames/monitor/nav/monitor_logout.jsp",
            processData: false,
            async: false,
            dataType: 'text', 
            success: function(data){
            	alert(data.trim());
            }
        });	
		location.reload();
	});
}

/* 重置监控缓存信息方法 */
function regMonitorReload(){
	$("#reloadMonitorCache").click(function(e){			
		$.ajax({
            type: "POST",
            url:MUtil.getRootPath()+"/frames/monitor/nav/monitor_reload.jsp",
            processData: false,
            async: false,
            dataType: 'text', 
            success: function(data){
            	alert(data.trim());
            }
        });	
		location.reload();
	});
}